GO ?= go
SRC = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
EXECUTABLE := server
VERSION := v0.0.1
BUILD := $(shell git rev-parse --verify HEAD | cut -c1-10)
PROJECT = smart-monitor-admin
GOPROXY = "https://goproxy.cn,direct"

LDFLAGS := $(LDFLAGS) -X "$(PROJECT)/version/version.Version=$(VERSION)" \
					  -X "$(PROJECT)/version/version.Build=$(BUILD)"

clean:
	rm -f $(EXECUTABLE)

build: $(EXECUTABLE)

$(EXECUTABLE): $(SRC) clean
	GO111MODULE=on GOPROXY=$(GOPROXY) $(GO) build \
		-ldflags '-s -w $(LDFLAGS)' \
		$(PROJECT)/cmd/$@
